/**
 * Copyright (c) 2007, Ashish Lijhara
 * All rights reserved.
 *
 * BGPanel.java
 *
 */

package crazy.java.Aetas;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author Ashish (Java Crazy)
 */
public class BGPanel extends JPanel{
    
    /** Initialize */
    BufferedImage backImage;
    /** Creates a new instance of BGPanel */
    public BGPanel(){
        loadImage();
    }
    public BGPanel(LayoutManager layout){
        super(layout);
        loadImage();
        
    }
    /** Load the image */
    public void loadImage(){
        
        try {
            File file = new File("res/BG.png");
            backImage = ImageIO.read(new URL(file.toURI().toURL().toString()));
        } catch(IOException e) {
            e.printStackTrace();
        }
        
    }
    
    /**
     * Paints the background of the panel.
     * remove the comments below to get a gradient background
     * @param g
     */
    public void paintComponent(Graphics g){
        Graphics2D g2d=(Graphics2D)g;
        float width=getWidth();
        float height=getHeight();
        g2d.drawImage(backImage,0,0,null);
        
        /*GradientPaint p=new GradientPaint(0, 0, new Color(0x202737),0, height, new Color(0x000000));
        g2d.setPaint(p);
        g2d.fillRect(0,0, getWidth(), getHeight());*/
        
    }
}

